﻿@{
    string spaceKey = ViewData.Get<string>("spaceKey", string.Empty);
    long groupId = ViewData.Get<long>("groupId", -99);
    string groupName = ViewData.Get<string>("groupName", string.Empty);
}
@using (Html.BeginAjaxForm("EditFollowedUsersGroup", "Follow", new { spaceKey = Url.SpaceKey(), groupId = groupId }, FormMethod.Post, new AjaxFormOptions { OnSuccessCallBack = "success" }, new { id = "EditFollowedUsersGroup" }))
{
    <div class="tnc-dailog-pd tnc-create-user-group">
        <div class="tn-form tn-form-single">
            @Html.TextBox("groupName", groupName, InputWidthTypes.Medium, new RouteValueDictionary { { "MaxLength", 32 } })
            @Html.Button("确认", ButtonTypes.Submit, HighlightStyles.Primary, htmlAttributes: new { id = "groupNameBut" })
        </div>
    </div>
}
<script type="text/dialog">
@if (groupId > 0)
{
      @: this.title("编辑分组");
}
else
{
       @: this.title("创建分组");
}

</script>
<script type="text/javascript">
    function success(data) {
        window.location.href = data.Data.url;
    }

    $(document).ready(function () {
        $("#groupNameBut").click(function () {
            if (!$("#EditFollowedUsersGroup").valid())
                return false;
        });
        $("#EditFollowedUsersGroup").validate({
            rules: {
                groupName: {
                    required: true,
                    maxBlength: 8
                }
            },
            messages: {
                groupName: {
                    required: "请输入分组名称",
                    maxBlength: "最多输入8个汉字"
                }
            }
        });
    });

</script>
